<template>
	<div class="panel-overlay "></div>
	<div class="panel panel-right panel-cover theme-dark" id="panel-right">
		<div>
			<div class="right-log">TopScanOL</div>
		</div>
		<div class="list-block list-margin">
			<ul class="rightmenu">
				<li>
					<a class="button" href="/#/project.new">新建项目</a>
				</li>
				<li>
					<a class="button" href="/#/project.list">项目列表</a>
				</li>
				<li>
					<a class="button" href="/#/task.new">新建任务</a>
				</li>
				<li>
					<a class="button" href="/#/task.list">其它任务</a>
				</li>
				<li>
					<a class="button" href="/#/setting.plugin">插件中心</a>
				</li>
				<li>
					<a class="button" href="/#/user.info">哈希爆破</a>
				</li>
				<li>
					<a class="button" href="/#/user.info">端口查询</a>
				</li>
				<li>
					<a class="button" href="/#/user.info">域名查询</a>
				</li>
				<li>
					<a class="button" href="/#/user.info">个人中心</a>
				</li>
			</ul>
		</div>
		
		<nav class="bar bar-tab">
		  <a class="tab-item" href="/#/setting">
		    <span class="icon icon-settings"></span>
		    <span class="tab-label">设置</span>
		  </a>
		  <a class="tab-item " href="/#/user.login">
		    <span class="icon icon-me"></span>
		    <span v-show="!isLogin" class="tab-label">登录</span>
		    <span v-show="isLogin" class="tab-label">退出</span>
		  </a>
		</nav>

	</div>
</template>

<script>
	export default {
		methods: {
			eBind(){
				var _self = this;
				$('#panel-right').on('opened',function(){
					$(this).off('closed');
				});
				$('.rightmenu a').click(function(){
					if(!$(this).is('.out')){
						var url = $(this).prop('href');
						$('#panel-right').on('closed',function(){
							location.href = url;
						});
						$.closePanel();
					}else{
						var cookies = document.cookie.split(';');
						var token = '';
						for(var i=0; i<cookies.length; i++){
							if(cookies[i].split('=')[0]=='token')break;
						}
						if(i < cookies.length)token = cookies[i].split('=')[1];
						$.ajax({
							url: './user',
							data: {"token": token},
							dataType: 'json',
							async: false,
							success: function(msg){
								if(msg.code==1){
									$.toast('已退出登录');
									_self.loginOut();
									$('#panel-right').on('closed',function(){
										location.href = "/#/user.login";
									});
									$.closePanel();
								}else{
									$.toast(msg.message);
								}
							},
							cache:false
						});
					}
				});
			}
		},

		ready(){
			this.eBind()
		}
	}
</script>
<style scoped>
	
</style>